package com.db4o.odbgen.unittesting;

import java.io.File;
import java.io.IOException;

import junit.framework.Assert;

import org.junit.Test;

import com.db4o.odbgen.OdbGen;
import com.db4o.odbgen.OdbgenException;
import com.db4o.odbgen.plugins.maingenerator.java.typedxmlschema.DataType;


/**
 * 
 * @author liviug
 * 
 */
public class GeneratorTests {
	@Test public void compareObjectSchemas() throws IOException, OdbgenException{
		File resultDir = new File("./results/generatortests/compareObjectSchemas");
		File testdataDir = new File("./testdata/generatortests/compareObjectSchemas/initialize");
		
		
		OdbGen og = new OdbGen();
		og.getOptions().setProperty("inputDirectory", testdataDir.getCanonicalPath());
		og.getOptions().setProperty("outputDirectory", resultDir.getCanonicalPath());
		og.getOptions().setProperty("rootPackage", "test.root.package");
		
		og.start();
		
		
		//TODO: Compare the results with the expected data.
	}
	
	@Test public void testDataType() throws IOException, OdbgenException{
		String sourceType = "List<intList<int,Map<StringList<int,Map<String, int>, int>, int>, int>,Map<StringList<intList<intList<int,Map<String, intList<int,Map<String, int>, int>>, int>,Map<StringList<int,Map<String, intList<int,Map<String, int>, int>>, int>, int>, int>,Map<String, intList<int,Map<StringList<int,Map<String, int>, int>, int>, int>>, int>, int>, intList<int,Map<StringList<int,Map<String, int>, int>, int>, int>>";
		DataType dt = new DataType(sourceType);
		String resType = dt.toString();
		
		sourceType = sourceType.replaceAll("\\s", "");
		resType = resType.replaceAll("\\s", "");

		Assert.assertEquals(sourceType, resType);
	}
	
}




